package com.vn.gofriends.adapter;

import java.util.ArrayList;
import java.util.List;

import com.vn.gofriends.R;
import com.vn.gofriends.item.PlaceItem;
import com.vn.gofriends.item.Trip;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class PlaceAdapter extends ArrayAdapter<PlaceItem>{
	
	ArrayList<PlaceItem> placeList;
	Context context;
	int resource;

	public PlaceAdapter(Context context, int resource,ArrayList<PlaceItem> Places) {
		super(context, resource, Places);
		this.placeList = Places;
		this.context = context;
		this.resource = resource;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = convertView;
		if (view == null) {
			view = ((LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
					.inflate(resource, parent, false);
		}
		PlaceItem place = placeList.get(position);
		if (place != null) {
			TextView txtItemNamePlace = (TextView) view
					.findViewById(R.id.txtItemNamePlace);
			TextView txtItemAddressPlace = (TextView) view
					.findViewById(R.id.txtItemAddressPlace);
			txtItemNamePlace.setText(place.getPlaceName());
			txtItemAddressPlace.setText(place.getAddress());
		}
		return view;
	}
}
